import React, { Component } from 'react';

import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';

import store from '../stores/main';

export default class Alert extends Component {

    constructor(props) {
        super(props)
    }

    handleClose () {
      this.setState(store.dispatch({type: 'CLOSE_ALERT'}));
    };

    render() {
        const actions = [
          <FlatButton
            label="确认"
            primary={true}
            onTouchTap={this.handleClose.bind(this)}
            />,
        ];
        var state = store.getState();
        return (
            <div>
              <Dialog
                actions={actions}
                modal={false}
                open={state.alt}
                onRequestClose={this.handleClose.bind(this)}
                >
                {state.text}
              </Dialog>
            </div>
        )
    }
}
